<html>
<head><meta charset="utf-8"><title>Adjust lint level on `cargo doc` invocations · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adjust.20lint.20level.20on.20.60cargo.20doc.60.20invocations.html">Adjust lint level on `cargo doc` invocations</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="222153815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adjust%20lint%20level%20on%20%60cargo%20doc%60%20invocations/near/222153815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ruby Lazuli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adjust.20lint.20level.20on.20.60cargo.20doc.60.20invocations.html#222153815">(Jan 09 2021 at 04:50)</a>:</h4>
<p>[I'm not sure if this is the right place to post this, so please direct me to the right stream if it isn't]<br>
Is there a way to adjust a lint's level when running <code>cargo doc</code>? I'd like to use <code>cargo doc --document-private-items</code> in a Git pre-commit hook to verify that my crates' documentation doesn't have any issues, and to help with this I'd like to forbid <code>broken_intra_doc_links</code>. I'm using a workspace, so a method that only touches the <code>cargo doc</code> invocation would be preferable (if such a solution exists).</p>
<p>Thanks in advance for any help!</p>



<a name="222154271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adjust%20lint%20level%20on%20%60cargo%20doc%60%20invocations/near/222154271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adjust.20lint.20level.20on.20.60cargo.20doc.60.20invocations.html#222154271">(Jan 09 2021 at 05:02)</a>:</h4>
<p><span class="user-mention" data-user-id="338659">@Ruby Lazuli</span> to pass flags directly to rustdoc, you can use <code>RUSTDOCFLAGS</code> or <code>cargo rustdoc</code>. If you just want to forbid the intra-doc links warning though, you can add <code>#![deny(broken_intra_doc_links)]</code> in the crate root, since those warnings are only emitted by rustdoc.</p>



<a name="222154308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adjust%20lint%20level%20on%20%60cargo%20doc%60%20invocations/near/222154308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adjust.20lint.20level.20on.20.60cargo.20doc.60.20invocations.html#222154308">(Jan 09 2021 at 05:03)</a>:</h4>
<p>Btw <code>cargo doc</code> takes a little long for me personally to want it in a pre commit hook, you might consider adding it to CI instead</p>



<a name="222154795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adjust%20lint%20level%20on%20%60cargo%20doc%60%20invocations/near/222154795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ruby Lazuli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adjust.20lint.20level.20on.20.60cargo.20doc.60.20invocations.html#222154795">(Jan 09 2021 at 05:15)</a>:</h4>
<p>Thank you, setting <code>RUSTDOCFLAGS</code> worked! I wanted to avoid placing <code>forbid</code> attributes since I'm using a workspace which may (at this time) gain crates at any time, and I didn't want to forget to add the attribute to any new crate roots.</p>
<p><code>cargo doc</code> does seem a bit slow, but I'm used to waiting longer for compiles in exchange for safety :P Thanks for the nudge about CI, by the way. I'm committing directly to the <code>main</code> branch right now since the project is still in a prototype phase, so CI wouldn't stop me until after the fact, but I'll definitely set it up for other contributors.</p>



<a name="222155496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adjust%20lint%20level%20on%20%60cargo%20doc%60%20invocations/near/222155496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adjust.20lint.20level.20on.20.60cargo.20doc.60.20invocations.html#222155496">(Jan 09 2021 at 05:34)</a>:</h4>
<p>FWIW I've been working on performance lately, so rustdoc should be significantly faster on nightly: <a href="https://perf.rust-lang.org/compare.html?start=2020-10-01&amp;end=2020-01-08&amp;stat=instructions%3Au">https://perf.rust-lang.org/compare.html?start=2020-10-01&amp;end=2020-01-08&amp;stat=instructions%3Au</a></p>



<a name="222155777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Adjust%20lint%20level%20on%20%60cargo%20doc%60%20invocations/near/222155777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ruby Lazuli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Adjust.20lint.20level.20on.20.60cargo.20doc.60.20invocations.html#222155777">(Jan 09 2021 at 05:42)</a>:</h4>
<p>I'm not sure why I said 'slow'; it's certainly not instant like <code>git commit</code> with no pre-commit hook, but adding a doc comment to every crate in the workspace leads to <code>git commit .</code> only taking 4.175 seconds on my machine (on nightly, timed with <code>time</code>). That's definitely reasonable enough for me :)<br>
(Also, thank you for your continued work on rustdoc!)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>